﻿using CalendarWindowsApp.Tools;
using Windows.UI.Xaml;

namespace CalendarWindowsApp.Behaviors
{
    public class StretchToParentBehavior : BehaviorBase
    {
        protected override void OnAttached()
        {
            var uiElment = AssociatedObject as FrameworkElement;
            uiElment.Loaded += (s, e) =>
            {
                var parent = uiElment.TryFindParent<FrameworkElement>();
                if (parent != null)
                {
                    uiElment.Width = parent.ActualWidth;
                    uiElment.Height = parent.ActualHeight;
                }
            };
            base.OnAttached();
        }
    }
}